package jee.boot.oauth.config.exception;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import jee.boot.common.basic.result.ResponseMessage;
import jee.boot.common.basic.result.Result;

import java.io.IOException;

public class CustomOauthExceptionSerializer extends StdSerializer<CustomOauthException> {
	private static final long serialVersionUID = 1L;

	public CustomOauthExceptionSerializer() {
		super(CustomOauthException.class);
	}

	@Override
	public void serialize(CustomOauthException authException, JsonGenerator gen, SerializerProvider provider) throws IOException {

		ResponseMessage<Object> error = Result.requestError(authException.getCusMsg());
		gen.writeObject(error);
	}
}
